# 字符串
data01 = '1'
data02 = "1"

# 原始字符 r

# 格式化字符串
# 占位符 %s   %f  %.2f f是精度,  %d是位数  %.2d 表示2位
# a = 1
# b = 2
# print("结果为:%s斤%s两" % (a, b))

# province = input("请输入省份:")
# quezhen = int(input("请输入确诊人数:"))
# zhiyu = int(input("请输入治愈人数:"))
# zhiyulv = zhiyu / quezhen
#
# print("%s确诊%s人,至于%s人,确诊率%.2f" % (province, quezhen, zhiyu, zhiyulv))

# 想要显示一个%, 需要写上2个%

# in   not in

# times = int(input("请输入次数:"))
# for num in range(times):
#     if num == 0 or num == times - 1:
#         print("*" * times)
#     else:
#         # print("*" + " " * (times - 2) + "*")
#         print("*%s*" % (" " * (times - 2)))


# 容器名字[] 取值从0开始,到len(容器名)-1,   也可以倒着来,从-1开始,到 -len(容器名)

# 容器切片 容器名[整数:整数:整数]  ,左开右闭 [  )

# 倒序字符串 容器名[::-1]

# message = "我是京师监狱狱长金海."
# print(message[0])
# print(message[-1: -4: -1])
# print(message[int(len(message) / 2)]) # //
# print("金海" in message)
# print("京师监狱" not in message)
# print(message[-3: -9: -1])
# print(message[::3])

# 列表  创建
# province_list = ['台湾', '陕西', '浙江']
# add_list = [16, 182, 2]
# now_list = [2239, 859, 505]
# sum_list = [16931, 1573, 2008]

# 列表添加
# 追加 append()
# 插入 insert(1, "xxx")

# 定位
# 读取


# province_list.append('广西')
# print(province_list)
# province_list.insert(0, '香港')
# print(province_list)
# add_list.insert(0, 196)
# now_list.insert(0, 12598)
# sum_list.insert(0, 12189)
# print('%s地区新增%s人现有%s人' % (province_list[0], add_list[0], now_list[0]))
# province_list[-2:] = ["ZJ", "GX"]
# print(province_list)


# province_list = ['台湾', '陕西', '浙江']
# add_list = [16, 182, 2]
# now_list = [2239, 859, 505]
# sum_list = [16931, 1573, 2008]
#
# for item in province_list:
#     print(item)

# print(range(len(add_list)))

# for i in range(len(add_list)):
#     add_list[i] += 1
#     print(add_list)
# print(i)

# province_list.remove('浙江')
# print(province_list)
#
# del now_list[:2]
# print(now_list)
#
# del sum_list[:]
# print(sum_list)
#
# del add_list[1]
# print(add_list)


# del删除 根据索引删除
# del add_list[1]
# print(add_list)

# 根据内容删除
# add_list.remove(2)
# print(add_list)

# planet_list = ["水星", "金星", "火星", "木星"]
#
# planet_list.insert(2, "地球")
# # planet_list.append("海王星")
# planet_list += ["海王星", "火星", "木星"]
# print(planet_list)
# print(planet_list[0])
# print(planet_list[len(planet_list) - 1])
# print(planet_list[:2])
# planet_list.remove("海王星")

# list01 = ["北京", "上海"]
# list02 = list01
# list01[0] = "广东"
# list03 = list01[:] #通过切片会创建出一个新的列表
# list03[-1] = ["深圳"]
# print(list01)

# name = 'xiaohuahua'
# print(f'这个人叫{name}')

# list01 = [1, 2, 3, 4, 5, 4, 3, 2, 1]
# for i in range(len(list01)):
#     print('*' * list01[i])

# list02 = [5, 1, 4, 6, 7, 4, 6, 8, 5]
# mut = 1
# for i in range(len(list02)):
#     mut *= list02[i]
# print(mut)

# list01 = ["北京", "上海", "深圳"]
# list02 = list01
# list01.insert(0,"天津")
# del list01[1]
# print(list02)

# 浅拷贝:第一层数据2份,深层数据1份
# 修改第一层数据,互不影响
# 修改第二层数据,就会相互影响
# 深拷贝,所有层,修改数据都互不影响

# import copy
# list01 = ["北京",["上海","深圳"]]
# list02 = list01
# list03 = list01[:]
# list04 = copy.deepcopy(list01)
# list04[0] = "北京04"
# list04[1][1] = "深圳04"
# print(list01) # ?
#
# list03[0] = "北京03"
# list03[1][1] = "深圳03"
# print(list01) # ?
# list02[0] = "北京02"
# list02[1][1] = "深圳02"
# print(list01) # ?

# 列表转换为字符串 .join(列表)
# join(), 将列表以字符串形式分割

# tmp_list = []
# in_str = ""
# while True:
#     in_str = input("请输入一个字符串")
#     if in_str != "":
#         tmp_list.append(in_str)
#     else:
#         break
# fin_str = "_".join(tmp_list)
# print(fin_str)


# 字符串表位列表 str -> list

# tmp_str = "孙悟空,八戒,沙和尚"
# tmp_list = tmp_str.split(",")
# print(tmp_list)

# tmp_str = "To have a government that is of people by people for people"
# 转换后：people for people by people of is that government a have To
# tmp_list = tmp_str.split(" ")
# fin_str = " ".join(tmp_list[::-1])
# print(fin_str)


# 列表推导式
# 生成10--30之间能被3或者5整除的数字

# tmp_list = []
# for item in range(10, 31):
#     if item % 3 == 0 or item % 5 == 0:
#         tmp_list.append(item)
# print(tmp_list)

# print(tmp_list(item for item in range(10, 31) if item % 3 == 0 or item % 5 == 0))

# 这里第一个item是放入新列表的项, 比如平方,item ** 2
# new_list = [item for item in range(10, 31) if item % 3 == 0 or item % 5 == 0]
# print(new_list)

# tmp_list = []
# for item in range(5, 21):
#     tmp_list.append(item ** 2)

# new_list = [item ** 2 for item in range(5, 21)]
# print(new_list)

# 格式化字符串

# minute = 9.3333
# second = 8.999
# print(f"{minute:.2f}:{second:.2f}")

# 元祖
# tuple01 = (1, 2, 3)
# 注意: 构建元祖可以不写小括号
# 只有一个元素时,元祖中必须写逗号

# tuple02 = 1, 2
# tuple03 = "123",
# list01 = [1, 2, 3]
# tuple04 = tuple(list01)
# print(tuple04)
# 序列可以拆包

# tuple_days = (31, 29, 31, 30)
# for item in tuple_days:
#     item += item
# print(item + 10)

# tuple_days = (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
# months = int(input("请输入月份:"))
# days = int(input("请输入日子:"))
# for index in range(len(tuple_days)):  # 也可以使用内建函数sum()进行计算
#     if months >= index + 1:
#         tmp_days += tuple_days[index]

# tmp_days = sum(tuple_days[:1])
# tmp_days += 1
# print(tmp_days)

# 字典

# dict_xxx = {
#     "name": "cwp",
#     "age": 29,
#     "sex": "男"
# }

# 还有一种必须可以一分为二
# print(dict([("xxx", "cwp")]))

# dict_taiwan = {
#     "region": "台湾",
#     "add": 16,
#     "now": 2339,
#     "all": 16931
# }
#
# dict_shanxi = {
#     "region": "陕西",
#     "add": 182,
#     "now": 859,
#     "all": 1573
# }
#
# dict_zhejiang = {
#     "region": "浙江",
#     "add": 2,
#     "now": 505,
#     "all": 2008
# }

# 添加
# dict_taiwan["total"] = 20000
# dict_taiwan["add"] = 3
# print(dict_taiwan["add"])

# 删除
# del dict_taiwan["total"]

# print(dict_taiwan["now"])
# print(f"陕西现有人数{dict_shanxi["add"]},新增人数{dict_shanxi["now"]}")
# dict_zhejiang["add"] += 1
# dict_zhejiang["now"] += 1
# print(dict_zhejiang)

# 遍历
# for key, value in dict_zhejiang.items():
#     print(key)
#     print(value)

# 字典装入列表中,默认装的是键,

# for key in dict_taiwan:
#     print(key)
#
# for value in dict_shanxi.values():
#     print(value)
#
# for item in dict_zhejiang.items():
#     print(item)
#
# for key in dict_shanxi:
#     if dict_shanxi[key] == 182:
#         print(key)


# list_room = [101, 102, 103]
# list_people = ["张", "赵", "周"]
# dict_people = {}
# for i in range(len(list_room)):
#     key = list_room[i]
#     value = list_people[i]
#     dict_people[key] = value
# print(dict_people)

# dict_people = {list_room[i]: list_people[i] for i in range(len(list_room))}
# print(dict_people)
#
# result_dict = {}
# for k, v in dict_people.items():
#     result_dict[v] = k
# print(result_dict)
#
# result_dict = {v: k for k, v in dict_people.items()}
# print(result_dict)
